package com.tbit.uqbike.service.rpcservice;

import java.util.Map;
import java.util.Random;

/**
 * @author MyWin E-mail:335918956@qq.com
 * @version 1.0
 * @createTime 2019-12-09 10:43
 */
public interface SmsService {

    public static final String CODE_LOGIN = "login";
    // code.业务.国家码.号码
    public static final String CODE_REDIS_KEY_FORMAT = "code.%s.%s.%s";

    public static Random CODE_RANDOM = new Random(System.currentTimeMillis());

    public static String getCodeRedisKey(String country, String phone, String type) {
        return String.format(CODE_REDIS_KEY_FORMAT, type, country, phone);
    }


    public static <T> T getAttr(Map<String, Object> param, String name, Class<T> clz) {
        Object obj = param.get(name);
        if (obj != null) {
            return (T) obj;
        }
        return null;
    }

    /**
     * 发送短信
     *
     * @param country
     * @param phone
     * @param content
     * @param exParam
     * @return
     */
    Map<String, Object> sendSms(String country, String phone, String content, Map<String, Object> exParam);

    /**
     * @param country
     * @param phone
     * @param code
     * @param type
     * @param param
     * @return
     */
    Map<String, Object> sendCode(String country, String phone, String code, String type, Map<String, Object> param);

}
